package com.wlc.base.temp;


import org.apache.commons.lang.StringUtils;
import org.springframework.http.converter.json.GsonBuilderUtils;

import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

/**
 * @author 王立朝
 * @description 临时类
 * @date 2021-11-11 09:38:49
 */
public class TempDemo {

    public static void main(String[] args) {

        test();
    }

    public static void test(){
        Map<String,Object> map = new HashMap<>(4);
        map.put("a",233);
        map.put("a",233);
        map.put("a",233);
        map.put("a",233);
        map.put("a",233);
        map.put(null,null);

    }
    public static void test02() {
        ArrayList arrayList = new ArrayList();
        arrayList.add(1);
        arrayList.add(2);
        arrayList.add(3);

        String string = (String) arrayList.stream().map(String::valueOf).collect(Collectors.joining(","));

        System.out.println("string = " + string);

    }

    public static void test01() {
        ArrayList arrayList = new ArrayList();
        arrayList.add(1);
        arrayList.add(2);
        arrayList.add(3);

        arrayList.stream().forEach(System.out::print);

        System.out.println("");
        String join = StringUtils.join(arrayList, ",");
        System.out.println("join = " + join);

    }

    //private static final List<String> list = Arrays.asList("1,2,3,5,6,4".split(","));
    private static final List<Integer> list = Arrays.asList(1,2,4,5,6,7,5,6,4);
    private static final List<String> list2 = Arrays.asList(
            "唐僧,悟空,八戒,沙僧,曹操,刘备,孙权".split(","));
    public static void test03() {
        System.out.println("list = " + list);

        Map<Boolean, List<Integer>> collect = list.stream().collect(Collectors.partitioningBy(i -> i > 3 ));
        System.out.println("collect = " + collect);

        System.out.println("====================");

        // 集合分隔
        List<String> list = list2.subList(0, 3);
        List<String> list3 = list2.subList(3, list2.size());
        // 打印集合中的元素
        list.forEach(i -> {
            System.out.println(i);
        });
        System.out.println("========================== ");
        list3.forEach(e-> System.out.println(e));
        System.out.println("---------------------");

        String join = StringUtils.join(list2, ",");
        System.out.println("join = " + join);

    }


}
